<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="en">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-32x32.ico?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="PHP,swoole," />





  <link rel="alternate" href="/atom.xml" title="JOE'S BLOG" type="application/atom+xml" />






<meta name="description" content="环境准备thinkphp5.1和swoole   tp5的安装使用composer安装，使用以下命令安装1composer create-project topthink/think  tp5  --prefer-dist  thinkphp5.1.18更新,完善了swoole的支持,不用再自己更改Request类了    ThinkPHP5.1.18版本发布——完善Swoole/Workerma">
<meta name="keywords" content="PHP,swoole">
<meta property="og:type" content="article">
<meta property="og:title" content="TP5集成Swoole">
<meta property="og:url" content="https://joewt.com/2018/06/20/thinkphpMeetsSwoole/index.html">
<meta property="og:site_name" content="JOE&#39;S BLOG">
<meta property="og:description" content="环境准备thinkphp5.1和swoole   tp5的安装使用composer安装，使用以下命令安装1composer create-project topthink/think  tp5  --prefer-dist  thinkphp5.1.18更新,完善了swoole的支持,不用再自己更改Request类了    ThinkPHP5.1.18版本发布——完善Swoole/Workerma">
<meta property="og:locale" content="en">
<meta property="og:image" content="http://img.hnitoj.cn/figure1.1.png">
<meta property="og:image" content="http://img.hnitoj.cn/figure1.2.png">
<meta property="og:image" content="http://img.hnitoj.cn/figure1.3.png">
<meta property="og:image" content="http://img.hnitoj.cn/figure1.4.png">
<meta property="og:image" content="http://img.hnitoj.cn/figure1.6.png">
<meta property="og:image" content="http://img.hnitoj.cn/figure1.7.png">
<meta property="og:updated_time" content="2018-10-19T07:09:33.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="TP5集成Swoole">
<meta name="twitter:description" content="环境准备thinkphp5.1和swoole   tp5的安装使用composer安装，使用以下命令安装1composer create-project topthink/think  tp5  --prefer-dist  thinkphp5.1.18更新,完善了swoole的支持,不用再自己更改Request类了    ThinkPHP5.1.18版本发布——完善Swoole/Workerma">
<meta name="twitter:image" content="http://img.hnitoj.cn/figure1.1.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://joewt.com/2018/06/20/thinkphpMeetsSwoole/"/>





  <title>TP5集成Swoole | JOE'S BLOG</title>
  








</head>



<body itemscope itemtype="http://schema.org/WebPage" lang="en">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">JOE'S BLOG</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">好记性不如烂键盘</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-book">
          <a href="/book/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            book
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://joewt.com/2018/06/20/thinkphpMeetsSwoole/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="JOE">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/assets/img/favicon1.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="JOE'S BLOG">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">TP5集成Swoole</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-06-20T20:45:28+08:00">
                2018-06-20
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Swoole/" itemprop="url" rel="index">
                    <span itemprop="name">Swoole</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2018/06/20/thinkphpMeetsSwoole/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count gitment-comments-count" data-xid="/2018/06/20/thinkphpMeetsSwoole/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">Words count in article&#58;</span>
                
                <span title="Words count in article">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">Reading time &asymp;</span>
                
                <span title="Reading time">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="环境准备"><a href="#环境准备" class="headerlink" title="环境准备"></a>环境准备</h2><p>thinkphp5.1和swoole  </p>
<p>tp5的安装使用composer安装，使用以下命令安装<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">composer create-project topthink/think  tp5  --prefer-dist</span><br></pre></td></tr></table></figure></p>
<blockquote>
<p>thinkphp5.1.18更新,完善了swoole的支持,不用再自己更改Request类了  </p>
</blockquote>
<p><a href="http://www.thinkphp.cn/topic/57791.html" target="_blank" rel="noopener"><br>ThinkPHP5.1.18版本发布——完善Swoole/Workerman支持</a></p>
<p>swoole的安装参考我写的swoole安装教程  </p>
<h2 id="swoole简单使用"><a href="#swoole简单使用" class="headerlink" title="swoole简单使用"></a>swoole简单使用</h2><a id="more"></a>
<p>一般来说我们的浏览器发起一个请求先走nginx或apache，然后通过fast_CGI交给php来执行php代码,FPM是fast_cgi的进程管理器,FPM通过一些配置管理很多的fast_cgi进程。<br>当我们使用swoole来开启一个http服务的话就不需要使用fpm了。</p>
<p>首先看官方文档的一个例子  </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">$http = new swoole_http_server(&quot;127.0.0.1&quot;, 9501);</span><br><span class="line">//在收到一个http请求后，会调用该函数</span><br><span class="line">$http-&gt;on(&apos;request&apos;, function ($request, $response) &#123;</span><br><span class="line">    //发送http响应体，结束请求处理</span><br><span class="line">    $response-&gt;end(&quot;&lt;h1&gt;Hello Swoole. #&quot;.rand(1000, 9999).&quot;&lt;/h1&gt;&quot;);</span><br><span class="line">&#125;);</span><br><span class="line">$http-&gt;start();</span><br></pre></td></tr></table></figure>
<p>如果想加载静态的html文件，可以使用document_root配置  </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">$http = new swoole_http_server(&quot;127.0.0.1&quot;, 9501);</span><br><span class="line">//worker_num设置启动的worker进程数</span><br><span class="line">$http-&gt;set(</span><br><span class="line">    [</span><br><span class="line">        &apos;enable_static_handler&apos; =&gt; true,</span><br><span class="line">        &apos;document_root&apos; =&gt; &quot;/thinkphp/public/static/live&quot;,</span><br><span class="line">        &apos;worker_num&apos; =&gt; 5,</span><br><span class="line">    ]</span><br><span class="line">);</span><br><span class="line"></span><br><span class="line">$http-&gt;on(&apos;request&apos;, function ($request, $response) &#123;</span><br><span class="line">    $response-&gt;end(&quot;&lt;h1&gt;Hello Swoole. #&quot;.rand(1000, 9999).&quot;&lt;/h1&gt;&quot;);</span><br><span class="line">&#125;);</span><br><span class="line">$http-&gt;start();</span><br></pre></td></tr></table></figure>
<p>使用命令行运行该程序，打开浏览器即可看到结果,这里就不给结果了。  </p>
<h2 id="tp5结合swoole"><a href="#tp5结合swoole" class="headerlink" title="tp5结合swoole"></a>tp5结合swoole</h2><p>首先把上面的http_server的代码放到tp5的项目目录下，我是放到了项目的根目录下<br><img src="http://img.hnitoj.cn/figure1.1.png" alt="">  </p>
<ul>
<li><p>如果我们不修改，当我们输入url的时候并不会找到相应的控制器方法。swoole通过request事件，通过回调函数处理相应的请求get,post等。  </p>
</li>
<li><p>通过swoole的workerstart事件回调函数加载框架代码</p>
</li>
<li><p>通过观察tp5的代码可以看到,index.php首先加载了引导文件start.php, start.php又加载了base.php文件。我们要加载的便是该文件  </p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">$http-&gt;on(&apos;WorkerStart&apos;,function(swoole_server $server,$worker_id)&#123;</span><br><span class="line">    define(&apos;APP_PATH&apos;, __DIR__ . &apos;/../application/&apos;);</span><br><span class="line">    // 这里 引入 base.php  而不引入start.php  是因为</span><br><span class="line">    // start.php 的话 就会执行thinkphp 的相应的控制器方法了</span><br><span class="line">    require __DIR__ . &apos;/../thinkphp/base.php&apos;;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<hr>
<p>这样便把tp5的代码加载到worker进程里,接着处理请求部分<br>因为tp5使用原生的php代码，所以需要把swoole的请求转换下。swoole接收get，post跟原生的不一样。  </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">$http-&gt;on(&apos;request&apos;, function ($request, $response) use($http)&#123;</span><br><span class="line">    if(isset($request-&gt;server))&#123;</span><br><span class="line">        foreach($request-&gt;server as $k =&gt; $v)&#123;</span><br><span class="line">            $_SERVER[strtoupper($k)] = $v;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    if(isset($request-&gt;server))&#123;</span><br><span class="line">        foreach($request-&gt;server as $k =&gt; $v)&#123;</span><br><span class="line">            $_SERVER[strtoupper($k)] = $v;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    //swoole对于超全局数组并不会释放，所以要先清空一次</span><br><span class="line">    $_GET = [];</span><br><span class="line">    if(isset($request-&gt;get))&#123;</span><br><span class="line">        foreach ($request-&gt;get as $k =&gt; $v)&#123;</span><br><span class="line">            $_GET[$k] = $v;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    $_POST = [];</span><br><span class="line">    if(isset($request-&gt;post))&#123;</span><br><span class="line">        foreach ($request-&gt;post as $k =&gt; $v)&#123;</span><br><span class="line">            $_POST[$k] = $v;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    //把返回放到一个缓冲区里</span><br><span class="line">    ob_start();</span><br><span class="line">    try &#123;</span><br><span class="line">        think\Container::get(&apos;app&apos;, [defined(&apos;APP_PATH&apos;) ? APP_PATH : &apos;&apos;])</span><br><span class="line">            -&gt;run()</span><br><span class="line">            -&gt;send();</span><br><span class="line">    &#125;catch(\Exception $e)&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    echo request()-&gt;action();</span><br><span class="line">    $res = ob_get_contents();</span><br><span class="line">    ob_end_clean();</span><br><span class="line">    $response-&gt;end($res);</span><br><span class="line"></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<p>这样改完后我们测试下 </p>
<p><img src="http://img.hnitoj.cn/figure1.2.png" alt=""></p>
<p><img src="http://img.hnitoj.cn/figure1.3.png" alt="">  </p>
<p><img src="http://img.hnitoj.cn/figure1.4.png" alt=""> </p>
<p>我们发现当我们修改方法时，始终显示的是index方法，这里有一个解决办法。</p>
<p>找到thinkphp/library/think/Request.php文件,里面有2个方法更改如下  </p>
<p><img src="http://img.hnitoj.cn/figure1.6.png" alt=""><br><img src="http://img.hnitoj.cn/figure1.7.png" alt="">  </p>
<p>之后我们就可以正常的通过url进行访问了。这里改成这样的原因，是因为tp会把模块，控制器，方法放到一个变量中，如果我们有重复访问同一个控制器，方法时这样比较高效。但worker进程并不会注销变量。就造成了访问不同控制器，方法始终是同一个控制器，方法。</p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>感谢土豪</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>Donate</span>
  </button>
  <div id="QR" style="display: none;">

    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/assets/img/alipay.png" alt="JOE Alipay"/>
        <p>Alipay</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>Post author:</strong>
    JOE
  </li>
  <li class="post-copyright-link">
    <strong>Post link:</strong>
    <a href="https://joewt.com/2018/06/20/thinkphpMeetsSwoole/" title="TP5集成Swoole">https://joewt.com/2018/06/20/thinkphpMeetsSwoole/</a>
  </li>
  <li class="post-copyright-license">
    <strong>Copyright Notice: </strong>
    All articles in this blog are licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> unless stating additionally.
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/PHP/" rel="tag"># PHP</a>
          
            <a href="/tags/swoole/" rel="tag"># swoole</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div id="needsharebutton-postbottom">
            <span class="btn">
              <i class="fa fa-share-alt" aria-hidden="true"></i>
            </span>
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/06/06/pthread/" rel="next" title="线程(十一)上">
                <i class="fa fa-chevron-left"></i> 线程(十一)上
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/07/10/daemons/" rel="prev" title="守护进程(十三)">
                守护进程(十三) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      
        <div id="gitment-container"></div>
      
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/assets/img/favicon1.png"
                alt="JOE" />
            
              <p class="site-author-name" itemprop="name">JOE</p>
              <p class="site-description motion-element" itemprop="description">爱生活，爱coding</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">22</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">9</span>
                  <span class="site-state-item-name">categories</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">11</span>
                  <span class="site-state-item-name">tags</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/yinrenxin" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:joewttx@163.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://learnerwn.github.io" title="Murphy" target="_blank">Murphy</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://strcpy.me" title="virusdefender" target="_blank">virusdefender</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://qulongjun.com/" title="落苏" target="_blank">落苏</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://tysb7.cn/" title="汤圆" target="_blank">汤圆</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://aconion.com" title="阿葱" target="_blank">阿葱</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://csy-anxuanxun.cn" title="csy" target="_blank">csy</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://hakana.cn" title="幻梦" target="_blank">幻梦</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.fastrun.cn" title="CrazyCodes" target="_blank">CrazyCodes</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.heanny.cn" title="Heanny" target="_blank">Heanny</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://vkkevin.xyz" title="Kevin" target="_blank">Kevin</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#环境准备"><span class="nav-number">1.</span> <span class="nav-text">环境准备</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#swoole简单使用"><span class="nav-number">2.</span> <span class="nav-text">swoole简单使用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#tp5结合swoole"><span class="nav-number">3.</span> <span class="nav-text">tp5结合swoole</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">JOE</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>








        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  








  







<!-- LOCAL: You can save these files to your site and update links -->
    
        
        <link rel="stylesheet" href="https://billts.site/extra_css/gitment.css">
        <script src="https://billts.site/js/gitment.js"></script>
    
<!-- END LOCAL -->

    

    
      <script type="text/javascript">
      function renderGitment(){
        var gitment = new Gitmint({
            id: window.location.pathname, 
            owner: 'Joewt',
            repo: 'blogComment',
            
            lang: "" || navigator.language || navigator.systemLanguage || navigator.userLanguage,
            
            oauth: {
            
            
                client_secret: 'aeba4f8f14a7d3464ef3ea9faef0d67409229e47',
            
                client_id: '12908903defa4c3347b8'
            }});
        gitment.render('gitment-container');
      }

      
      renderGitment();
      
      </script>
    







  





  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">

  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "box";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
  </script>

  

  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?0c58a1486de42ac6cc1c59c7d98ae887"></script><script>L2Dwidget.init({"model":{"jsonPath":"/live2dw/assets/koharu.model.json"},"display":{"position":"left","width":75,"height":150},"mobile":{"show":true},"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/"});</script></body>
</html>
